package com.vegetable.modules.service.stock;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.vegetable.modules.entity.stock.Stock;
import com.vegetable.modules.entity.stock.StockFlow;
import com.vegetable.modules.entity.stock.po.StockFlowQueryPO;
import com.vegetable.modules.entity.stock.to.StockFlowDTO;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 库存表 服务类
 * </p>
 *
 * @author wangruijie
 * @since 2024-03-21
 */
public interface IStockFlowService extends IService<StockFlow> {

    /**
     * 库存流水列表查询
     * @param po
     * @return
     */
    IPage<StockFlowDTO> stockFlowList(StockFlowQueryPO po);

    IPage<StockFlowDTO> statisticsStockFlow(StockFlowQueryPO po);

    Map<String, Object> stockFlowLists(StockFlowQueryPO po);

    Map<String, Object> stockFlowLists2(StockFlowQueryPO po);

    /**
     * 根据订单号查询库存流水
     * @param orderNo
     * @return
     */
    List<StockFlowDTO> queryFlowByOrderNo(String orderNo);

    List<StockFlowDTO> queryInFlowByOrderNo(String orderNo);

    List<StockFlowDTO> queryOutFlowByOrderNo(String orderNo, Long orderId);

    List<StockFlowDTO> queryPackOutFlowByOrderNo(String orderNo, Long orderId);

    List<StockFlowDTO> queryOutFlowByOrderNo(String orderNo, Long orderId, Long detailId);


    /**
     * 新增库存流水
     * @param stock 库存信息
     * @param orderType 出入库单据类型
     * @param num 调整数量
     * @param surplusStock 调整后数量
     * @param orderNo 出入库订单编码
     * @return
     */
    int addStockFlow(Stock stock, Integer orderType, BigDecimal num, String orderNo, String targetName, Date orderTime);

    /**
     * 删除订单的库存流水
     * @param docNo
     */
    void deleteByOrderNo(String docNo);

}
